package com.bjqh.edu.UI.dialog;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.bjqh.edu.R;


/**
 * Created by Administrator on 2016/11/11 0011.
 */
public class LoadDialog extends ProgressDialog {
    private static LoadDialog dialog;
    private ProgressBar progress;
    public TextView message;
    private static String messageValue;

    public LoadDialog(Context context, String messageValue) {
        super(context, R.style.WhiteDialog);
        this.messageValue = messageValue;

    }
    public static Dialog initDialog(Context context, String messageValue) {
        if (null == dialog) {
            dialog = new LoadDialog(context, messageValue);
        } else if (dialog.isShowing()) {
            dialog.dismiss();
            dialog = new LoadDialog(context, messageValue);
        } else {
            dialog = new LoadDialog(context, messageValue);
        }

        if (!dialog.isShowing()) {
            dialog.show();
        }

        return dialog;

    }

    public static void closeDialog() {
        if (null!=dialog&&dialog.isShowing())
            dialog.dismiss();
    }


    public LoadDialog(Context context, int theme) {
        super(context, theme);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading_dialog);
        progress = (ProgressBar) findViewById(R.id.grogress);
        message = (TextView) findViewById(R.id.id_tv_loadingmsg);
        message.setText(messageValue);
        dialog.setCanceledOnTouchOutside(false);
    }

    @Override
    public boolean isIndeterminate() {
        return false;
    }
}
